/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package brain;

import Globals.AllGlobal;
import com.jme3.math.FastMath;
import controller.MyController;
import model.ZuanKong_Model;
import myfx.jfxpanel.JStatusBarImpl;
import myfx.jfxpanel.MyMenu;

import myfx.jfxpanel.MyTreeContainer;
import myjme.JmeCanvas;

/**
 *
 * @author Administrator
 */
public class MyBrain {
    private MyTreeContainer fxContainer;
    private MyMenu fxMenu;
    private JStatusBarImpl myStatus;
    private JmeCanvas jmeCanvas;
    private MyController controller;
    public MyBrain(MyTreeContainer fxContainer,MyMenu fxMenu,JStatusBarImpl myStatus,JmeCanvas jmeCanvas,MyController controller){
        this.fxContainer=fxContainer;
        this.fxMenu=fxMenu;
        this.myStatus=myStatus;
        this.jmeCanvas=jmeCanvas;
        this.controller=controller;
        AddBrainAll();
    }
    public void AddBrainAll(){
        fxContainer.addBrain(this);
        fxMenu.addBrain(this);
        myStatus.addBrain(this);
        jmeCanvas.addBrain(this);
        controller.addBrain(this);
    }
    public float CaculateR(float kongshen,float kxl,float yzx,float v,int shapeType){
        float r=0.0f;
        if(shapeType== AllGlobal.CYLINDER_TYPE){
//            r=(float)Math.sqrt(v/(FastMath.PI*(1-kxl)*kongshen));
//            r=(float)Math.sqrt(v/(Math.PI*(kxl)*kongshen));
            r=(float)FastMath.sqrt(v/(FastMath.PI*(1-kxl)*kongshen));
            return r;
        }else if(shapeType==AllGlobal.CUBOID_TYPE){
//            float y=(float)Math.sqrt(v/((1-kxl)*yzx*kongshen));//延展性我写为x/y
            float y=(float)Math.sqrt(v/((kxl)*yzx*kongshen));//延展性我写为x/y
            return y;
        }
        return 1;
    }
    public float CaculateR(ZuanKong_Model zuanKong_Model,int shapeType){
        float r=0.0f;
//        if(shapeType== AllGlobal.CYLINDER_TYPE){
//            r=(float)Math.sqrt(v/(Math.PI*kxl*kongshen));
//            return r;
//        }else if(shapeType==AllGlobal.CUBOID_TYPE){
//            float y=(float)Math.sqrt(v/(kxl*yzx*kongshen));//延展性我写为x/y
//            return y;
//        }
        return 1;      
    }
    //为2d准备的
    public float CaculateR_2D(float kongshen,float kxl,float yzx,float v,int shapeType){
        float r=0.0f;
        if(shapeType== AllGlobal.CYLINDER_TYPE){
//            r=(float)Math.sqrt(v/(FastMath.PI*(1-kxl)*kongshen));
            r=(float)Math.sqrt(v/(Math.PI*(kxl)*kongshen))*2;
//            r=(float)FastMath.sqrt(v/(FastMath.PI*(1-kxl)*kongshen));
            return r;
        }else if(shapeType==AllGlobal.CUBOID_TYPE){
//            float y=(float)Math.sqrt(v/((1-kxl)*yzx*kongshen));//延展性我写为x/y
            float y=(float)Math.sqrt(v/((kxl)*yzx*kongshen))*2;//延展性我写为x/y
            return y;
        }
        return 1;
    }
}
